package com.sem.example2.client;

import java.io.BufferedReader;
import java.io.IOException;

public class ReadDataListening implements Runnable{

	private BufferedReader reader = null;
	private boolean isListening = true;
	
	public ReadDataListening(String name , BufferedReader in){
		this.reader = in;
	}
	public void run() {
		while(reader != null && isListening){
			try {
				// 从Server读入一字符串，并打印到标准输出上
				String line = reader.readLine();
				System.out.println(line);
			} catch (IOException e) {
				System.err.println("Server read data error!");
				e.printStackTrace();
			}
		}
	}
	
	/**
	 * @return the isListening
	 */
	public boolean isListening() {
		return isListening;
	}
	/**
	 * @param isListening the isListening to set
	 */
	public void setListening(boolean isListening) {
		this.isListening = isListening;
	}
}
